package com.myapplication;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;

import java.lang.reflect.Field;

public class CustomViewPager extends ViewPager {
    public CustomViewPager(Context context) {
        super(context);
    }

    public CustomViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public boolean isBeginDragged() {
        try {
            Field isBeingDragged = ViewPager.class.getDeclaredField("mIsBeingDragged");
            isBeingDragged.setAccessible(true);

            Object obj = isBeingDragged.get(this);
            if (obj != null) {
                return (boolean) obj;
            }
        } catch (Throwable r) {
            r.printStackTrace();
        }

        return false;
    }
}
